import { NativeModules } from "react-native";
import DeviceInfo from "react-native-device-info";

import { isIOS } from "../common";

const { RNBridgeModule } = NativeModules;

const deviceName = DeviceInfo.getDeviceId();

export const getDeviceName = () => {
  return new Promise(resolve => {
    if (isIOS) {
      switch (deviceName) {
        case "iPhone1,1":
          resolve("iPhone 1G");
          break;
        case "iPhone1,2":
          resolve("iPhone 3G");
          break;
        case "iPhone2,1":
          resolve("iPhone 3GS");
          break;
        case "iPhone3,1":
          resolve("iPhone 4");
          break;
        case "iPhone3,2":
          resolve("iPhone 4 Verizon");
          break;
        case "iPhone4,1":
          resolve("iPhone 4S");
          break;
        case "iPhone5,2":
          resolve("iPhone 5");
          break;
        case "iPhone5,3":
          resolve("iPhone 5c");
          break;
        case "iPhone5,4":
          resolve("iPhone 5c");
          break;
        case "iPhone6,1":
          resolve("iPhone 5s");
          break;
        case "iPhone6,2":
          resolve("iPhone 5s");
          break;
        case "iPhone7,1":
          resolve("iPhone 6 Plus");
          break;
        case "iPhone7,2":
          resolve("iPhone 6");
          break;
        case "iPhone8,1":
          resolve("iPhone 6s");
          break;
        case "iPhone8,2":
          resolve("iPhone 6s Plus");
          break;
        case "iPhone8,4":
          resolve("iPhone SE");
          break;
        case "iPhone9,1":
          resolve("iPhone 7");
          break;
        case "iPhone9,2":
          resolve("iPhone 7 Plus");
          break;
        case "iPhone9,3":
          resolve("iPhone 7");
          break;
        case "iPhone9,4":
          resolve("iPhone 7 Plus");
          break;
        case "iPhone10,1":
          resolve("iPhone 8 Global");
          break;
        case "iPhone10,2":
          resolve("iPhone 8 Plus Global");
          break;
        case "iPhone10,3":
          resolve("iPhone X Global");
          break;
        case "iPhone10,4":
          resolve("iPhone 8 GSM");
          break;
        case "iPhone10,5":
          resolve("iPhone 8 Plus GSM");
          break;
        case "iPhone10,6":
          resolve("iPhone X GSM");
          break;

        case "iPhone11,2":
          resolve("iPhone XS");
          break;
        case "iPhone11,4":
          resolve("iPhone XS Max (China)");
          break;
        case "iPhone11,6":
          resolve("iPhone XS Max");
          break;
        case "iPhone11,8":
          resolve("iPhone XR");
          break;

        case "i386":
          resolve("Simulator 32");
          break;
        case "x86_64":
          resolve("Simulator 64");
          break;

        case "iPad1,1":
          resolve("iPad");
          break;
        case "iPad2,1":
        case "iPad2,2":
        case "iPad2,3":
        case "iPad2,4":
          resolve("iPad 2");
          break;
        case "iPad3,1":
        case "iPad3,2":
        case "iPad3,3":
          resolve("iPad 3");
          break;
        case "iPad3,4":
        case "iPad3,5":
        case "iPad3,6":
          resolve("iPad 4");
          break;
        case "iPad4,1":
        case "iPad4,2":
        case "iPad4,3":
          resolve("iPad Air");
          break;
        case "iPad5,3":
        case "iPad5,4":
          resolve("iPad Air 2");
          break;
        case "iPad6,3":
        case "iPad6,4":
          resolve("iPad Pro 9.7-inch");
          break;
        case "iPad6,7":
        case "iPad6,8":
          resolve("iPad Pro 12.9-inch");
          break;
        case "iPad6,11":
        case "iPad6,12":
          resolve("iPad 5");
          break;
        case "iPad7,1":
        case "iPad7,2":
          resolve("iPad Pro 12.9-inch 2");
          break;
        case "iPad7,3":
        case "iPad7,4":
          resolve("iPad Pro 10.5-inch");
          break;

        case "iPad2,5":
        case "iPad2,6":
        case "iPad2,7":
          resolve("iPad mini");
          break;
        case "iPad4,4":
        case "iPad4,5":
        case "iPad4,6":
          resolve("iPad mini 2");
          break;
        case "iPad4,7":
        case "iPad4,8":
        case "iPad4,9":
          resolve("iPad mini 3");
          break;
        case "iPad5,1":
        case "iPad5,2":
          resolve("iPad mini 4");
          break;
        case "iPod1,1":
          resolve("iTouch");
          break;
        case "iPod2,1":
          resolve("iTouch2");
          break;
        case "iPod3,1":
          resolve("iTouch3");
          break;
        case "iPod4,1":
          resolve("iTouch4");
          break;
        case "iPod5,1":
          resolve("iTouch5");
          break;
        case "iPod7,1":
          resolve("iTouch6");
          break;
        default:
          resolve("");
          break;
      }
    } else {
      RNBridgeModule.getSystemModel(systemModle => {
        resolve(systemModle);
      });
    }
  });
};

export const getPlantName = () => {};
